cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
project(AsyncioExample)

if(NOT CMAKE_BUILD_TYPE)
    set(CMAKE_BUILD_TYPE Debug CACHE STRING "Build type" FORCE)
endif()
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
message(STATUS "System Name: ${CMAKE_SYSTEM_NAME}")

message(STATUS "Is the C++ compiler loaded? ${CMAKE_CXX_COMPILER_LOADED}")
if (CMAKE_CXX_COMPILER_LOADED)
    message(STATUS "The C++ compiler ID is: ${CMAKE_CXX_COMPILER_ID}")
    message(STATUS "Is the C++ from GNU? ${CMAKE_COMPILER_IS_GNUCXX}")
    message(STATUS "The C++ compiler version is: ${CMAKE_CXX_COMPILER_VERSION}")
endif ()

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${PROJECT_SOURCE_DIR}/bin)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${PROJECT_SOURCE_DIR}/bin)

if (WIN32)
	set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4819")
	set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DWIN32_LEAN_AND_MEAN")
else ()
	find_program(CCACHE_FOUND ccache)
	if(CCACHE_FOUND)
		set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
		set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
	endif(CCACHE_FOUND)
	set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 -g -pthread -Wno-deprecated-declarations ")
endif ()

include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../opt/asio-1.18.2/include)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../include)

add_subdirectory(${PROJECT_SOURCE_DIR}/1.simple_client)
add_subdirectory(${PROJECT_SOURCE_DIR}/2.simple_server)
add_subdirectory(${PROJECT_SOURCE_DIR}/3.chat_client)
add_subdirectory(${PROJECT_SOURCE_DIR}/4.chat_server)
add_subdirectory(${PROJECT_SOURCE_DIR}/5.load_test_client)
add_subdirectory(${PROJECT_SOURCE_DIR}/6.load_test_server)
add_subdirectory(${PROJECT_SOURCE_DIR}/7.gproto_test_client)
add_subdirectory(${PROJECT_SOURCE_DIR}/8.gproto_test_server)
add_subdirectory(${PROJECT_SOURCE_DIR}/9.http_server)
add_subdirectory(${PROJECT_SOURCE_DIR}/10.user_client)
add_subdirectory(${PROJECT_SOURCE_DIR}/11.user_server)
add_subdirectory(${PROJECT_SOURCE_DIR}/12.conn_test_client)